#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def calc_sum(*args):
    ax = 0
    for n in args:
        ax = ax + n
    return ax


print(calc_sum(1,2,3))
print(calc_sum(2))   

  

def lazy_sum(*args):
	def sum():
		ax = 0
		for n in args:
			ax = ax + n
		return ax
	return sum

f = lazy_sum(1,231,41,1231)
print(f)
print(f())    


def count():
	fs=[]
	for i in range(1,4):
		def f():
			return i*i
		fs.append(f)	
	return fs

f1,f2,f3=count()

print(f1(),f2(),f3())


def count2():
	def f2(j):
		def g2():
			return j*j
		return g2
	fs=[]
	for i in range(1,4):
	    fs.append(f2(i))
	return fs

d1,d2,d3=count2()

print(d1(),d2(),d3())


def createCounter():
	js=0
	def counter():
		nonlocal js
		js=js+1
		return js
	return counter

fn=createCounter()

for x in range(1,10):
    print(fn())	


